package org.puremvc.as3.multicore.core
{
	import org.puremvc.as3.multicore.interfaces.IView;
	
	public class ReView extends View
	{
		public function ReView(key:String)
		{
			super(key);
		}
		
		/**
		 * View Singleton Factory method.
		 * 
		 * @return the Singleton instance of <code>View</code>
		 */
		public static function getInstance( key:String ) : IView 
		{
			if ( instanceMap[ key ] == null ) 
				instanceMap[ key ] = new ReView( key );
			return instanceMap[ key ];
		}

		/**
		 * Remove an IView instance
		 * 
		 * @param multitonKey of IView instance to remove
		 */
		public static function removeView( key:String ):void
		{
			var view:ReView = getInstance( key ) as ReView;
			if (view != null) {
				for (var mediator:String in view.getMediatorMap()) {
					view.removeMediator( mediator );
				}
			}
			
			delete instanceMap[ key ];
		}
		
		protected function getMediatorMap():Array {
			return mediatorMap;
		}
	}
}